<!DOCTYPE html>
<html>
  <head>
    <title>Rhizosphere</title>
    <!--
      Uncomment the following script tag to enable detailed logging of
      Rhizosphere history management functions.
    -->
    <!--
    <script>
      rhizosphereHistoryLogLevel = 'debug';
    </script>
    -->

   <!--
    Google services integration. Autoloads:
    - google visualization APIs.
   -->
    <script type="text/javascript" src="http://www.google.com/jsapi?autoload=%7Bmodules%3A%5B%7Bname%3Avisualization%2Cversion%3A1%7D%5D%7D"></script>

    <!-- AppEngine channels -->
    {% if use_channels %}
      <script src='/_ah/channel/jsapi'></script>
    {% endif %}

    <!-- Rhizosphere libraries and styles -->
    {% include "rhizo_head.html" %}
    {% include "ga.html" %}
  </head>
  <body>
    <div id="rhizo-pangea" style="position: absolute; top: 0; bottom: 0; right: 0; left: 0;">
    </div>

    <script type="text/javascript" charset="utf-8">
      // Expose the visualization user-agent as a global variable, to let the
      // user programmatically drive the visualization via the browser
      // javascript console.
      var ua;
      $(document).ready(function() {
        {% if use_channels %}
          // TODO(battlehorse): Broadcasting should rely on capabilities to
          // decide whether to activate itself or not, rather than URL
          // experimental parameters.
          rhizo.ui.component.templates['broadcast'] = function(project) {
            var template;
            if (project.gui().isSmall() || project.gui().isMobile()) {
              template = new rhizo.ui.component.BottomTemplate(
                  project, 'bottom');
              template.addtoBottomBar(new rhizo.broadcast.BaseComponent(
                  project));
            } else {
              template = new rhizo.ui.component.StandardTemplate(
                  project, 'default');
              template.addtoLeftBar(new rhizo.broadcast.BaseComponent(
                  project));
            }
            return template;
          };
        {% endif %}

        var options = {
          logLevel: {% if logLevel %}'{{ logLevel }}'{% else %}null{% endif %},
          allowConfigFromUrl: true
          {% if use_channels %}
            ,template: 'broadcast'
          {% else %}
            {% if template %}
            ,template: '{{template}}'
            {% endif %}
          {% endif %}
          {% if platform %}
          ,platform: '{{platform}}'
          {% endif %}
          {% if device %}
          ,device: '{{device}}'
          {% endif %}
        };
        var bootstrapper = new rhizo.bootstrap.Bootstrap(
            $('#rhizo-pangea'), options);
        ua = bootstrapper.prepareAndDeploy();
      });
    </script>
  </body>
</html>
